<template>
  <div class="home_wrap">
    <a-layout class="public_layout" id="components-layout-demo-custom-trigger">
      <a-layout-sider v-model="collapsed" :trigger="null" collapsible>
        <div class="logo">可爱的前端小哥哥</div>
        <a-menu theme="dark" mode="inline" :default-selected-keys="['1']" @click="handleClick">
          <a-menu-item key="userMan">
            <a-icon type="user" />
            <span>用户管理</span>
          </a-menu-item>
          <a-sub-menu key="sub1">
            <span slot="title">
              <a-icon type="ordered-list" />
              <span>文章管理</span>
            </span>
            <a-menu-item key="artCat">文章分类</a-menu-item>
            <a-menu-item key="addArt">添加文章</a-menu-item>
            <a-menu-item key="Artlist">文章列表</a-menu-item>
          </a-sub-menu>
          <a-menu-item key="imgMan">
            <a-icon type="camera" />
            <span>图片管理</span>
          </a-menu-item>
          <a-menu-item key="own">
            <a-icon type="credit-card" />
            <span>个人简历</span>
          </a-menu-item>
        </a-menu>
      </a-layout-sider>
      <a-layout>
        <a-layout-header style="background: #fff; padding: 0">
          <a-icon
            class="trigger"
            :type="collapsed ? 'menu-unfold' : 'menu-fold'"
            @click="() => (collapsed = !collapsed)"
          />
        </a-layout-header>
        <a-layout-content
          :style="{ margin: '24px 16px', padding: '24px', background: '#fff', minHeight: '280px' }"
        >
          <router-view></router-view>
        </a-layout-content>
      </a-layout>
    </a-layout>
  </div>
</template>

<script>
export default {
  data () {
    return {
      collapsed: false
    }
  },
  methods: {
    handleClick (e) {
      console.log(e)
      this.$router.push(`/${e.key}`)
    }
  }
}
</script>

<style lange='scss' scoped>
.home_wrap {
  height: 100%;
}
.public_layout {
  height: 100%;
}
#components-layout-demo-custom-trigger .trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}

#components-layout-demo-custom-trigger .trigger:hover {
  color: #1890ff;
}

#components-layout-demo-custom-trigger .logo {
  height: 32px;
  margin: 16px;
  color: #1890ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
</style>
